Skip to content

bugfix(specialpower): Fix availability of building based special powers #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mauller
Copy link

@Mauller Mauller commented Aug 10, 2025

This PR fixes some issues that cropped up in Generals Online, caused by an earlier fix that was meant to prevent some special power exploits in non retail code. The earlier fix initialises the available frame to max int to prevent some exploits.

Essentially most of the USA special powers stopped working and the battleplans on the strategy center also stopped working.

This PR fixes this by checking if we are a special power module for a building that does not have a public timer, then setting the available frame for the power to the current frame.

The public timer case prevents super weapons from getting their timers reset to zero again and the building check means it only affects building based special powers. These special powers are typically immediately available once the building is constructed and do not have any other form of initialisation code.


TODO

  • Check unlocked special powers still work the same way as retail

…the current frame to make them immediately available
@Mauller Mauller self-assigned this Aug 10, 2025
@Mauller Mauller added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour ThisProject The issue was introduced by this project, or this task is specific to this project labels Aug 10, 2025
@Mauller Mauller changed the title fix(nonRetail): set building based special powers available frame to the current frame to make them immediately available fix(nonRetail): fix availability of building based special powers in non retail code Aug 10, 2025
@xezon xezon added Major Severity: Minor < Major < Critical < Blocker and removed Minor Severity: Minor < Major < Critical < Blocker labels Aug 11, 2025
@xezon xezon changed the title fix(nonRetail): fix availability of building based special powers in non retail code bugfix(specialpower): Fix availability of building based special powers Aug 11, 2025
@xezon xezon added the NoRetail This fix or change is not applicable with Retail game compatibility label Aug 11, 2025
// This means we need to set their available frame to the current frame to make them usable
// The check for a public timer excludes super weapons from the selection criteria
if (getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() == FALSE &&
getObject()->isKindOf(KINDOF_STRUCTURE) )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a Mod creates this kind of setup on something that is not a structure? Is the KINDOF_STRUCTURE test really necessary?

Copy link
Author

@Mauller Mauller Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infantry don't seem to be affected by this issue, but that could also be because their special powers have been setup in a different way that initialises their special power timer on unit creation.

I still need to double check some powers to make sure they are working still.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just !getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() not enough? If not, why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure yet, i would need to test first, but it was only building based powers that were not working when i did initially check.

Will do some more testing tomorrow.

Copy link
Author

@Mauller Mauller Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just !getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() not enough? If not, why?

so normal unit creation works down this path

	// if we're pre-built, start counting down
	if( !getObject()->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
	{
		//A sharedNSync special only startPowerRecharges when first scienced or when executed,
		//Since a new modue with same SPTemplates may construct at any time.
		if ( getSpecialPowerTemplate()->isSharedNSync() == FALSE )
			startPowerRecharge();
	}

if a unit has an ability that is instantly available, the reload time being set to zero makes it always available.

If i removed the building check in the code it would actually cause all powers to be instantly available.

When setting breakpoints the only times i see this code get entered is when the above code is not hit. Usually when a building is placed.

i think the reason for this is because a lot of these borken powers use the getSpecialPowerTemplate()->isSharedNSync() set to true, so only one instance of that power is available, like spy satelite and drone etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility ThisProject The issue was introduced by this project, or this task is specific to this project ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants